# -*- coding: utf-8 -*-
"""
创建日期: 2024/9/17   14:11

@author: justinc
@blog: https://blog.csdn.net/sjc122333?type=blog
@gitee: https://gitee.com/justinc666

"""
# 读取操作常见功能
# file_txt = open("./示例文件/作者.txt", mode="r", encoding="utf8")
# data_txt = file_txt.read(1)
# file_txt.close()
# print(data_txt)

# file_txt = open("./示例文件/作者.txt", mode="rb")
# data_txt = file_txt.read(1)
# file_txt.close()
# print(data_txt)

# # readline方法
# f = open("./示例文件/示例文本.txt", mode="r", encoding="utf-8")
# for i in range(5):
#     content = f.readline()
#     print(content)
# f.close()

# # readlines方法
# f = open("./示例文件/示例文本.txt", mode="r", encoding="utf-8")
# content = f.readlines()
# print(content)
# f.close()

# # 循环读取，无需判断
# f = open("./示例文件/示例文本.txt", mode="r", encoding="utf-8")
# for line in f:
#     print(line.strip())
# f.close()


# 写入常见功能
# flush，将内容刷入硬盘
# file_txt = open("./示例文件/作者.txt", mode="a", encoding="utf-8")
# file_txt.write("666")
# file_txt.flush()  # 直接刷入硬盘
# file_txt.close()

# # seek，将光标移动到指定字节
# f = open("./示例文件/作者.txt", mode="r+", encoding="utf-8")
#
# f.seek(7)
# f.write("_")
# f.close()


# # tell，获取光标位置
# f = open("./示例文件/示例文本.txt", mode="r", encoding="utf-8")
#
# biao1 = f.tell()
# print(biao1)
#
# f.read(3)  # 读取三个字符
#
# biao2 = f.tell()  # 当前光标在第九个字节的位置
# print(biao2)
# f.close()

# 上下文管理

with open("./示例文件/作者.txt", "r") as f1,open("./示例文件/作者_.txt", "r") as f2:
    context1 = f1.read()
    context2 = f2.read()
    print(context1, context2, sep="")
